package com.prognos.service.impl;

import com.prognos.domain.info.SourceDirectory;
import com.prognos.persistence.dao.SourceDirectoryDao;
import com.prognos.service.SourceDirectoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by chema on 2/12/14.
 */
@Service("SourceDirectoryService")
public class SourceDirectoryServiceImpl implements SourceDirectoryService {

    private final SourceDirectoryDao sourceDirectoryDao;

    @Autowired
    public SourceDirectoryServiceImpl(SourceDirectoryDao sourceDirectoryDao) {
        this.sourceDirectoryDao = sourceDirectoryDao;
    }

    @Override
    public List<SourceDirectory> getDirectoriesToHarvest() {
        return sourceDirectoryDao.findAll();
    }

    @Override
    @Transactional
    public void create(SourceDirectory sourceDirectory) {
        sourceDirectoryDao.saveOrUpdate(sourceDirectory);
    }
}
